package cn.buk.tms.entity.misc;

import com.fasterxml.jackson.annotation.JsonFormat;

import jakarta.persistence.*;
import java.util.Date;

/**
 * 发送到企业微信的任务卡片信息内容
 * @author yfdai
 */
@Entity
@Table(name="tms_ww_task")
public class TmsTask {

    //只读任务通知
    public static final int TMS_TASK_TYPE_GENERAL = 0;
    //选择任务通知
    public static final int TMS_TASK_TYPE_SIMPLE = 1;
    //每日审核任务
    public static final int TMS_TASK_TYPE_DAILY_AUDIT = 2;

    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private int id;

    @Column(name="enterprise_id")
    private int enterpriseId;

    /**
     * 任务类型
     * 0 - 普通通知
     * 1 - 选择通知（用于同意和拒绝的操作）
     */
    @Column(name = "task_type")
    private int taskType;

    /**
     * 标题
     */
    @Column(length=50)
    private String title;

    /**
     * 内容
     */
    @Column(length=200)
    private String content;

    /**
     * 订单类型
     * 使用TmsOrderConstant中的定义
     * public static final int ORDER_TYPE_FLIGHT = 1000; //机票预订单
     *   public static final int ORDER_TYPE_FLIGHT_REFUND = 1001; //机票退票单
     *   public static final int ORDER_TYPE_FLIGHT_CHANGE = 1002; //机票改签单
     */
    @Column(name = "order_type")
    private Integer orderType;

    /**
     * 订单号
     */
    @Column(name = "order_no")
    private String orderNo;

    /**
     * 订单id
     */
    @Column(name = "order_id")
    private Integer orderId;

    /**
     * 有些任务需要完成
     * 0/null - 未完成
     * 1 - 已完成
     */
    private Integer status;

    /**
     * 完成时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "done_date")
    private Date doneDate;

    /**
     * 发送文件完成时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "send_file_time")
    private Date sendFileTime;


    @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
    @Temporal(TemporalType.DATE)
    @Column(name = "create_date")
    private Date createDate;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_time", insertable = false, updatable = false)
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "last_update", insertable = false)
    private Date lastUpdate;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getEnterpriseId() {
        return enterpriseId;
    }

    public void setEnterpriseId(int enterpriseId) {
        this.enterpriseId = enterpriseId;
    }

    public int getTaskType() {
        return taskType;
    }

    public void setTaskType(int taskType) {
        this.taskType = taskType;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        if (title != null && title.length() > 50) {
            title = title.substring(0, 50);
        }
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        if (content != null && content.length() > 200) {
            content = content.substring(0, 200);
        }
        this.content = content;
    }

    public Integer getOrderType() {
        return orderType;
    }

    public void setOrderType(Integer orderType) {
        this.orderType = orderType;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public Date getLastUpdate() {
        return lastUpdate;
    }

    public void setLastUpdate(Date lastUpdate) {
        this.lastUpdate = lastUpdate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public int getOrderId() {
        return orderId == null ? 0 : orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public int getStatus() {
        return status == null ? 0 : status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getSendFileTime() {
        return sendFileTime;
    }

    public void setSendFileTime(Date sendFileTime) {
        this.sendFileTime = sendFileTime;
    }

    public Date getDoneDate() {
        return doneDate;
    }

    public void setDoneDate(Date doneDate) {
        this.doneDate = doneDate;
    }
}
